package cn.lhemi.iotweb.controller;

import cn.lhemi.iotweb.util.R;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * @author tutu11
 * @description 错误拦截
 * @date 2020-03-13 11:09:38
 */
@Controller
public class ErrController implements ErrorController {
    @Override
    public String getErrorPath() {
        return "/error";
    }

    @RequestMapping("/error")
    @ResponseBody
    @ResponseStatus(HttpStatus.NOT_FOUND)
    public R error() {
        return R.builder().code(HttpStatus.NOT_FOUND.value()).msg("Not Found").build();
    }
}
